package com.xhl.controller;


import com.xhl.entity.User;
import com.xhl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xhlMr
 * @since 2020-07-29
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("/all")
    public List<User> all(){
        return userService.list(null);
    }

    @RequestMapping("/quebyid/{id}")
    public User userService(@PathVariable("id") Integer id){
        System.out.println(id);
        return userService.userbyid(id);
    }

    @RequestMapping("/updbyid")
    public Integer updbyid(User user){

        return userService.updbyid(user);
    }

    @RequestMapping("/updid")
    public boolean updid(User user){

        return userService.updateById(user);
    }

    @RequestMapping("/delbyid/{id}")
    public Integer delbyid(@PathVariable("id") Integer id){
        System.out.println(id);

        return userService.delbyid(id);
    }

}

